package org.xdq.demo.emp.dao;

import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.*;
import org.xdq.demo.emp.dto.EmpDto;
import org.xdq.demo.emp.model.Employee;

import java.util.List;

@Mapper
public interface EmpDao {

    //@Select("select * from emp")
    List<Employee> findEmpList(EmpDto empDto);

    @Select("select * from emp where e_id = #{id}")
    Employee findEmpById(String eid);

    @Select("select count(e_id) from emp where e_id=#{id}")
    boolean findIsExistsEmpId(String e_id);

    @Insert("insert into emp(e_id,e_name,e_sal,e_date) values(#{e_id},#{e_name},#{e_sal},#{e_date})")
    void insertOneEmp(EmpDto empDto);

    @Update("update emp set e_name = #{e_name},e_sal=#{e_sal},e_date=#{e_date} where e_id = #{e_id}")
    void updateEmp(EmpDto empDto);

    //@Param("ids") 为 参数eids命名一个占位参数名为ids
    void deleteEmp(@Param("ids") String[] eids);
}
